package com.salton123.colorflydemo.ui.fm;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.salton123.colorflydemo.R;
import com.salton123.colorflydemo.widget.MandalaGestureView;
import com.salton123.ui.base.BaseFragment;

/**
 * User: newSalton@outlook.com
 * Date: 2019/5/22 18:53
 * ModifyTime: 18:53
 * Description:
 */
public class MandalaComp extends BaseFragment {
    private MandalaGestureView mMandalaGestureView;
    private ImageView ivSave;

    @Override
    public int getLayout() {
        return R.layout.comp_mandala;
    }

    @Override
    public void initVariable(Bundle savedInstanceState) {
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public void initViewAndData() {
        mMandalaGestureView = f(R.id.mandalaView);
        mMandalaGestureView.setImageResource(R.drawable.mandala_style_two);
        ivSave = f(R.id.ivSave);
        ivSave.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ivSave:
                boolean result = mMandalaGestureView.saveBitmap("/sdcard/mandala/" + System.currentTimeMillis() + ".png");
                if (result) {
                    shortToast("保存成功");
                } else {
                    shortToast("保存失败");
                }
                break;
        }
    }
}
